#include "mainwindow.h"

#include <QApplication>
#include <QDebug>
#include <QLabel>
#include <QLayout>
#include <QSettings>
#include <QTextCodec>
#include <QTextEncoder>

int main(int argc, char *argv[])
{
    QApplication a(argc, argv);
    QString filename = "/home/shanghf/kylin-offline-upgrade.conf";
    QSettings *offlineupgrade = new QSettings(filename, QSettings::IniFormat);
    offlineupgrade->setIniCodec("utf8");

    QString service = offlineupgrade->value("AUTO/service").toString();
    if (service != "enable")
        return -1;

    QString sourcepath;
    offlineupgrade->beginGroup("CONFIG");
    QByteArray sourcepath1 = offlineupgrade->value("path").toByteArray();
    offlineupgrade->endGroup();

    QTextCodec *codec = QTextCodec::codecForName("utf8");

    QByteArray encodedString = codec->fromUnicode(sourcepath1);
    QString encodedString1 = codec->toUnicode(sourcepath1);
    qDebug() << "the source1 path is " << sourcepath1;
    qDebug() << "the source1 path is " << encodedString;
    qDebug() << "the source1 path is " << encodedString1;

    qDebug() << "sourcepath" << sourcepath;
    qDebug() << "the source path is " << sourcepath;

    MainWindow w;
    w.init();

    w.show();
    return a.exec();
}
